package top.ewind.controller.admin;

import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

import top.ewind.controller.common.AdminRootCtrl;

public class AdminCtrl extends AdminRootCtrl {
	public void center() {
		Integer nid = getSessionAttr("nid");
		List<Record> feedbacklist = Db.find("select * from device_remind where nid = ? order by intime desc limit 20 ",nid);
		Record devicecon =  Db.findFirst("SELECT COUNT(*) as cond FROM device WHERE nid = ?",nid);
		Record  deviceoline =  Db.findFirst("SELECT COUNT(*) as cond FROM device WHERE stat = 2 and nid = ?",nid);
		Record deviceunline =  Db.findFirst("SELECT COUNT(*) as cond FROM device WHERE stat = 1 and  nid = ?",nid);
		Record deviceuser = Db.findFirst("select count(*) as duser from device_user where nid = ?",nid);
		Record newdevice =  Db.findFirst("SELECT COUNT(*) as newde FROM device WHERE intime IS NOT NULL AND worktime IS NULL and nid = ?",nid);
		Record expdevice =  Db.findFirst("SELECT COUNT(*) AS expde FROM device  WHERE exptime is not null and nid = ?",nid);
		Record adminconut =  Db.findFirst("SELECT count(*) as adminconut FROM sys_admin");	
		Record bootconut =  Db.findFirst("SELECT COUNT(*) as bootconut FROM device_boot where nid = ?",nid);	
		setAttr("feedbacklist",feedbacklist);
		setAttr("devicecon",devicecon);
		setAttr("deviceoline",deviceoline);
		setAttr("deviceunline",deviceunline);
		setAttr("deviceuser",deviceuser);
		setAttr("newdevice",newdevice);
		setAttr("expdevice",expdevice);
		setAttr("adminconut",adminconut);
		setAttr("bootconut",bootconut);
		render("center.html");
	}
	public void showusername(){
		Record uesr = getSessionAttr("sysuser");
		renderJson("msg",uesr.getStr("username"));
	}
	public void editadmin(){
		int userid = getSessionAttr("nid");
		renderJson("msg",userid);
	}
	public void ueditor() {
		render("demo/ueditor.html");
	}

	public void crop() {
		render("demo/crop.html");
	}
}
